<?php require_once('../includes/conn.php'); ?>
<?php
session_start();


if($_REQUEST["type"] == 'logo')
{
	$s1 = "SELECT port_image FROM portfolio_flash_work where port_id = '".$_REQUEST["code"]."'";
	$q1 = mysql_query($s1) or die($s1);
	$r1 = mysql_fetch_array($q1);
	
		if(is_file("../images/site/".$r1["port_image"]))
		{
			unlink("../images/site/".$r1["port_image"]);
		}
		
		$s = "update portfolio_flash_work set port_image = '' where port_id = '".$_REQUEST["code"]."'";
		$q = mysql_query($s) or die($s);
}
else
if($_REQUEST['type'] == 'home')
{
	$s1 = "SELECT home_image FROM homepage_images where home_id = '".$_REQUEST["code"]."'";
	$q1 = mysql_query($s1) or die($s1);
	$r1 = mysql_fetch_array($q1);
	
		if(is_file("../images/".$r1["home_image"]))
		{
			unlink("../images/".$r1["home_image"]);
		}
		
		$s = "update homepage_images set home_image = '' where home_id = '".$_REQUEST["code"]."'";
		$q = mysql_query($s) or die($s);
}
else
if($_REQUEST['type'] == 'gallery')
{
	$s1 = "SELECT gallery_image FROM gallery where gallery_id = '".$_REQUEST["code"]."'";
	$q1 = mysql_query($s1) or die($s1);
	$r1 = mysql_fetch_array($q1);
	
		if(is_file("../images/gallery/".$r1["gallery_image"]))
		{
			unlink("../images/gallery/".$r1["gallery_image"]);
		}
		
		$s = "update gallery set gallery_image = '' where gallery_id = '".$_REQUEST["code"]."'";
		$q = mysql_query($s) or die($s);
}
else
{
	$s1 = "SELECT mgnt_image FROM management_team where mgnt_id = '".$_REQUEST["code"]."'";
	$q1 = mysql_query($s1) or die($s1);
	$r1 = mysql_fetch_array($q1);
	
		if(is_file("../images/site/".$r1["mgnt_image"]))
		{
			unlink("../images/site/".$r1["mgnt_image"]);
		}
		
		$s = "update management_team set mgnt_image = '' where mgnt_id = '".$_REQUEST["code"]."'";
		$q = mysql_query($s) or die($s);
}
		 
   echo "<script language='javascript'>
   		alert('Successfully Updated the Records');
   		window.location ='".$_SERVER['HTTP_REFERER']."';
   		 </script>";  
?>